<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //1. 对象简写
        let name = "moduleA"
        let obj = {
            name, //name:name
            test1() { //方法可以简写为这样

            },
            [name + "test2"]() { //方法名也可以为表达式形式

            }
        }

        //2. 对象属性使用表达式
        let name1 = "a"
        let obj1 = {
            [name1 + "bc"]: "twj"
        }
        console.log(obj1) //{abc:'twj'}

        //3. 扩展运算符... ES2018支持
        let obj2 = {
            name: "twj"
        }
        let obj3 = {
            ...obj2
        }
        let obj4 = {
            age: 100
        }
        obj2.name = "whh"
        console.log(obj2) //{name: 'whh'}
        //console.log(...obj2, ...obj4) //报错

        //4. Object.assign：合并多个对象
        let obj5 = {
            name: "twj"
        }
        let obj6 = {
            age: 100
        }
        //影响的是obj5，可以用个空对象来接收返回的新对象
        console.log(Object.assign(obj5, obj6)) //{name: 'twj', age: 100}

        //5. Object.is：判断两个对象是否相等
        //因为 === 无法判断两个NaN是否相等，以及+0和-0是否相等
        console.log(Object.is(5, 5)) //true
        console.log(Object.is({}, {})) //false
        console.log(Object.is(NaN, NaN)) //true

        console.log(Object.is(+0, -0)) //false
        console.log(+0 === -0) //true
    </script>
</body>

</html>